package com.yipai.datewidget.booking.base;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import com.lxj.xpopup.core.BottomPopupView;

public class BaseBottomPopupView extends BottomPopupView {

    private FragmentActivity mActivity;

    public BaseBottomPopupView(@NonNull Context context) {
        super(context);
        mActivity = (FragmentActivity) context;
    }

    private ViewModelProvider mActivityProvider;

    public <T extends ViewModel> T getActivityScopeViewModel(@NonNull Class<T> modelClass) {
        if (mActivityProvider == null) {
            mActivityProvider = new ViewModelProvider(mActivity);
        }
        return mActivityProvider.get(modelClass);
    }
}
